<?php
// File Security Check
if ( ! empty( $_SERVER['SCRIPT_FILENAME'] ) && basename( __FILE__ ) == basename( $_SERVER['SCRIPT_FILENAME'] ) ) :
	die ( 'You do not have sufficient permissions to access this page!' );
endif;

/* Template Name: Send mail */

$sender_name = $_POST["your-name"];
$sender_email = $_POST["your-email"];
$sender_phonenumber = $_POST["your-phone"];
$sender_message = $_POST["your-message"];

if(isset($_POST["lp-action"])){
    $to = get_field("target");
    //$to = get_bloginfo( 'admin_email' );
    //$to = "jorgeferreyram@gmail.com";

    $subject = "Corporal Age - Contacto Formulario Web : $sender_name";

    $message = 
    "De: $sender_name <$sender_email>
    Asunto: $sender_name

    Cuerpo del mensaje:
    $sender_message

    --
    Este e-mail se ha enviado vía formulario de contacto desde Corporal Age http://www.corporalage.com/";

    $result = mail($to, $subject, $message);
}

get_header(); ?>

<?php get_template_part( 'page-title' ); ?>

<!-- BEGIN #container -->
<div id="container" class="clearfix">

    <!-- BEGIN #content -->
    <section id="content" class="full-width <?php echo $post->post_name; ?>">

        <?php if ( have_posts() ) : ?>

            <?php while ( have_posts() ) : the_post(); ?>

                <div class="entry clearfix">
                    <?php the_content( __( 'Continue reading', 'nicethemes' ) . ' &raquo;' ); ?>
                    <?php wp_link_pages( array( 'before' => '<div class="page-link">' . __( 'Pages:', 'nicethemes' ), 'after' => '</div>' ) ); ?>
                </div>

                <?php //comments_template( '', true ); ?>

            <?php endwhile; ?>

        <?php else : ?>

            <header>
                <h2><?php _e( 'Not Found', 'nicethemes' ); ?></h2>
            </header>
            <p><?php _e( 'Sorry, but you are looking for something that isn\'t here.', 'nicethemes' ); ?></p>

            <?php get_search_form(); ?>

        <?php endif; ?>

    <!-- END #content -->
    </section>

<!-- END #container -->
</div>

<?php get_footer(); ?>